package patrol.mobile.com.mobilepatrol.activity.security.emergency;

import android.util.Log;
import android.widget.ImageView;
import android.widget.ScrollView;
import android.widget.TextView;

import com.bumptech.glide.Glide;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import butterknife.BindView;
import patrol.mobile.com.mobilepatrol.R;
import patrol.mobile.com.mobilepatrol.activity.security.ConsTitles;
import patrol.mobile.com.mobilepatrol.activity.security.StickyEventBody;
import patrol.mobile.com.mobilepatrol.bean.PeopleInfoBean;
import patrol.mobile.com.mobilepatrol.fragment.BaseFragment;

public class EmergencyPeopleInfoBodyFragment extends BaseFragment{

    @BindView(R.id.tv_perName)
    TextView tvPerName;
    @BindView(R.id.tv_perSex)
    TextView tvPerSex;
    @BindView(R.id.tv_idCard)
    TextView tvIdCard;
    @BindView(R.id.tv_national)
    TextView tvNational;
    @BindView(R.id.tv_perType)
    TextView tvPerType;
    @BindView(R.id.tv_censusRegister)
    TextView tvCensusRegister;
    @BindView(R.id.tv_position)
    TextView tvPosition;
    @BindView(R.id.tv_company)
    TextView tvCompany;
    @BindView(R.id.tv_education)
    TextView tvEducation;
    @BindView(R.id.tv_political)
    TextView tvPolitical;
    @BindView(R.id.tv_familySize)
    TextView tvFamilySize;
    @BindView(R.id.tv_familyType)
    TextView tvFamilyType;
    @BindView(R.id.tv_familyAddress)
    TextView tvFamilyAddress;
    @BindView(R.id.tv_perMobile)
    TextView tvPerMobile;
    @BindView(R.id.tv_impSpec)
    TextView tvImpSpec;
    @BindView(R.id.tv_belief)
    TextView tvBelief;
    @BindView(R.id.tv_impSpecImfo)
    TextView tvImpSpecImfo;
    @BindView(R.id.tv_houseRented)
    TextView tvHouseRented;
    @BindView(R.id.tv_hrNo)
    TextView tvHrNo;
    @BindView(R.id.iv_people)
    ImageView ivPeople;
    @BindView(R.id.sc_info)
    ScrollView scrollView;


    @Override
    protected void initView() {
        super.initView();
        EventBus.getDefault().register(this);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_info_body;
    }

    @Override
    protected void initData() {
        EmergencyPeopleInfoActivity activity = (EmergencyPeopleInfoActivity) getActivity();
        activity.setMainTitle(ConsTitles.EMERGENCY_PEOPLE_INFO);

    }

    @Subscribe(threadMode = ThreadMode.MAIN,sticky = true)
    public void ReceviceMessage(StickyEventBody stickyEventBody){
        PeopleInfoBean protectListBean =stickyEventBody.protectListBean;
        tvPerName.setText(protectListBean.getPerName());
        tvPerSex.setText(protectListBean.getPerSex().equals("1") ? "男" :"女");
        tvIdCard.setText(protectListBean.getIdCard());
        tvNational.setText(protectListBean.getNational());
        tvPerType.setText(protectListBean.getPerType());
        tvCensusRegister.setText(protectListBean.getCensusRegister());
        tvPosition.setText(protectListBean.getPosition());
        tvCompany.setText(protectListBean.getCompany());
        tvEducation.setText(protectListBean.getEducation());
        tvPolitical.setText(protectListBean.getPolitical());
        tvFamilySize.setText(protectListBean.getFamilySize());
        tvFamilyType.setText(protectListBean.getFamilyType());
        tvFamilyAddress.setText(protectListBean.getFamilyAddress());
        tvPerMobile.setText(protectListBean.getPerMobile());
        tvImpSpec.setText(protectListBean.getImpSpec());
        tvBelief.setText(protectListBean.getBelief());
        tvImpSpecImfo.setText(protectListBean.getImpSpecImfo());
        tvHouseRented.setText(protectListBean.getHouseRented());
        tvHrNo.setText(protectListBean.getHrNo());
        Glide.
                with(EmergencyPeopleInfoBodyFragment.this)
                .load(baseUrl + protectListBean.getCoverImg())//.substring(2)
                .into(ivPeople);
    }


    @Override
    protected void initListener() {

    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().removeAllStickyEvents();
        EventBus.getDefault().unregister(this);
    }

}
